package com.bt.lms.ui.page.school_education.stu_mes_manage;


import com.bt.lms.ui.action.school_education.stu_msg_manage.GraduateMesAction;
import com.bt.lms.ui.action.school_education.stu_msg_manage.SchoolRecordMesAction;
import com.bt.lms.ui.action.school_education.stu_msg_manage.SchoolRegisterChangeMesAction;
import com.bt.lms.ui.action.school_education.stu_msg_manage.StudentBasicMesAction;
import com.bt.lms.ui.page.common.action.pagerecord.RecruitStuLabAction;
import com.bt.lms.ui.page.school_education.PageStudentList;
import com.bt.lms.ui.page.school_education.stu_basic.PageStudentBasicMes;
import javafx.collections.ObservableList;
import javafx.event.EventHandler;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Cursor;
import javafx.scene.Node;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Pane;
import javafx.scene.layout.VBox;

/**
 * 学员学籍信息管理主界面
 */
public class PageStudentMesManage extends VBox {


    public PageStudentMesManage() {
        Insets insets = new Insets(10);
        this.setPadding(insets);
        this.setSpacing(20);

        //初始化标题索引
        initTitleIndex();
        //初始化信息按钮
        initTitleList();
        //初始化基本信息盒子
        PageStudentBasicMes pageStudentBasicMes = new PageStudentBasicMes(this);
        this.getChildren().add(pageStudentBasicMes);

    }


    /**
     * 初始化信息按钮
     */
    private void initTitleList() {
        HBox hBox = new HBox();
        hBox.setSpacing(20);

        Button basicBtn = new Button("学员基本信息");
        Button statusBtn = new Button("学籍档案信息");
        Button transactionBtn = new Button("学籍异动信息");
        Button graduateBtn = new Button("就业信息");

        //给按钮加事件方法
        basicBtn.setCursor(Cursor.HAND);
        statusBtn.setCursor(Cursor.HAND);
        transactionBtn.setCursor(Cursor.HAND);
        graduateBtn.setCursor(Cursor.HAND);

        //维护一下，将界面传过去
        //学员基本信息按钮事件
        StudentBasicMesAction studentBasicMesAction = new StudentBasicMesAction(this);
        basicBtn.setOnAction(studentBasicMesAction);

        //学籍档案信息按钮事件
        SchoolRecordMesAction schoolRecordMesAction = new SchoolRecordMesAction(this);
        statusBtn.setOnAction(schoolRecordMesAction);
        //学籍异动信息按钮事件
        SchoolRegisterChangeMesAction schoolRegisterChangeMesAction = new SchoolRegisterChangeMesAction(this);
        transactionBtn.setOnAction(schoolRegisterChangeMesAction);
        //毕/结业信息按钮事件
        GraduateMesAction graduateMesAction = new GraduateMesAction(this);
        graduateBtn.setOnAction(graduateMesAction);


        ObservableList<Node> children = hBox.getChildren();
        children.addAll(basicBtn, statusBtn, transactionBtn, graduateBtn);
        this.getChildren().add(hBox);

    }


    /**
     * 初始化标题索引
     */
    private void initTitleIndex() {
        HBox hBox = new HBox();
        hBox.setPrefHeight(30);
        hBox.setSpacing(10);
        hBox.setAlignment(Pos.CENTER_LEFT);

        Label label = new Label("当前位置：🏠");
        Label label1 = new Label(">学籍管理");
        label1.setStyle("-fx-text-fill: #00ccff");
        //初始化学籍管理label的事件
        initLabel1Event(label1);


        Label label3 = new Label(">学籍信息管理");
        label3.setStyle("-fx-text-fill: #00ccff");
        Label label2 = new Label(">学员基本信息");
        hBox.getChildren().addAll(label, label1, label3, label2);


        this.getChildren().add(hBox);


    }

    /**
     * 初始化学籍管理label的事件
     *
     * @param label1 >学籍管理
     */
    private void initLabel1Event(Label label1) {

        //鼠标移动到label位置变颜色，变成小手图案
        label1.addEventHandler(MouseEvent.MOUSE_ENTERED_TARGET, new EventHandler<MouseEvent>() {
            @Override
            public void handle(MouseEvent event) {
                label1.setStyle("-fx-text-fill: red");//变成红颜色
                label1.setCursor(Cursor.HAND);//变成小手图案
            }
        });
        //鼠标退出时变回原来颜色
        label1.addEventHandler(MouseEvent.MOUSE_EXITED, new EventHandler<MouseEvent>() {
            @Override
            public void handle(MouseEvent event) {
                label1.setStyle("-fx-text-fill: #00ccff");
            }
        });
        //给标签添加事件，回退到学籍信息主页面
        label1.addEventHandler(MouseEvent.MOUSE_CLICKED, new EventHandler<MouseEvent>() {
            @Override
            public void handle(MouseEvent event) {
                PageStudentList pageStudentList = new PageStudentList();
                Pane pane = RecruitStuLabAction.pageSkipInfo.getPane();
                ObservableList<Node> children = pane.getChildren();
                Integer index = RecruitStuLabAction.pageSkipInfo.getIndex();
                children.set(index, pageStudentList);


            }
        });
    }
}
